package com.example.mydatabaseapp.data.infrastructure.context;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseOpenHelper extends SQLiteOpenHelper {
	public static final String SHAFT_POSITION_TABLE = "TBL001_SHAFT_POSITIONS";
	
	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "myLocalDB.db";
	
	public DatabaseOpenHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " + SHAFT_POSITION_TABLE +  
				"(_ID INTEGER PRIMARY KEY, NUMBER TEXT, NAME TEXT, LATITUDE TEXT, LONGITUDE TEXT)");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS" + SHAFT_POSITION_TABLE);
		onCreate(db);
	}
}
